package com.muyu.danmo.controller;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoSealCollection;
import com.muyu.danmo.service.IDanmoSealCollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 印章图片集Controller
 * 
 * @author yangle
 * @date 2024-11-25
 */
@RestController
@RequestMapping("/danmoSealCollection")
public class DanmoSealCollectionController extends BaseController
{
    @Autowired
    private IDanmoSealCollectionService danmoSealCollectionService;

    /**
     * 查询印章图片集列表
     */
//    @RequiresPermissions("system:danmoSealCollection:list")
    @PostMapping("/list")
    public Result<PageInfo<DanmoSealCollection>> list(@RequestBody DanmoSealCollection danmoSealCollection)
    {
        PageHelper.startPage(danmoSealCollection.getPageNum(), danmoSealCollection.getPageSize());
        List<DanmoSealCollection> list = danmoSealCollectionService.selectDanmoSealCollectionList(danmoSealCollection);
        PageInfo<DanmoSealCollection> danmoSealCollectionPageInfo = new PageInfo<>(list);
        return  Result.success(danmoSealCollectionPageInfo);
    }

    /**
     * 导出印章图片集列表
     */
//    @RequiresPermissions("system:danmoSealCollection:export")
    @Log(title = "印章图片集", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoSealCollection danmoSealCollection)
    {
        List<DanmoSealCollection> list = danmoSealCollectionService.selectDanmoSealCollectionList(danmoSealCollection);
        ExcelUtil<DanmoSealCollection> util = new ExcelUtil<DanmoSealCollection>(DanmoSealCollection.class);
        util.exportExcel(response, list, "印章图片集数据");
    }

    /**
     * 获取印章图片集详细信息
     */
//    @RequiresPermissions("system:danmoSealCollection:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return Result.success(danmoSealCollectionService.selectDanmoSealCollectionById(id));
    }

    /**
     * 新增印章图片集
     */
//    @RequiresPermissions("system:danmoSealCollection:add")
    @Log(title = "印章图片集", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public Result add(@RequestBody DanmoSealCollection danmoSealCollection)
    {
        return danmoSealCollectionService.insertDanmoSealCollection(danmoSealCollection);
    }

    /**
     * 修改印章图片集
     */
//    @RequiresPermissions("system:danmoSealCollection:edit")
    @Log(title = "印章图片集", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoSealCollection danmoSealCollection)
    {
        return  danmoSealCollectionService.updateDanmoSealCollection(danmoSealCollection);
    }

    /**
     * 删除印章图片集
     */
//    @RequiresPermissions("system:danmoSealCollection:remove")
    @Log(title = "印章图片集", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return danmoSealCollectionService.deleteDanmoSealCollectionByIds(ids);
    }
}
